package cn.felord.verse.event.listener;

import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.time.Duration;

/**
 * @author dax
 * @since 2023/10/24
 */
public class SpringBootApplicationReadyListener implements ApplicationListener<ApplicationReadyEvent> {
    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
// 启动时间
        Duration timeTaken = event.getTimeTaken();
        ConfigurableApplicationContext applicationContext = event.getApplicationContext();


//  spring name
        String id = applicationContext.getId();
        ConfigurableEnvironment environment = applicationContext.getEnvironment();

        String actives = String.join(",", environment.getActiveProfiles());
        String port = environment.getProperty("server.port");


    }
}
